﻿using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
#if !(WINDOWS_PHONE || ANDROID)
using Syngine.Input.Mouse;
#endif
namespace Syngine.Input
{
	/// <summary>
	/// 
	/// </summary>
	public struct InputState
	{
		private bool _isNotDefault;
#if !(WINDOWS_PHONE || ANDROID)
		private MouseState _mouseState;
		private MarqueeState _marqueeState;
#endif
		private TouchCollection _touchState;
		private KeyboardState _keyboardState;

#if !(WINDOWS_PHONE || ANDROID)
		/// <summary>
		/// 
		/// </summary>
		public MouseState MouseState
		{
			get
			{
				return _mouseState;
			}
			internal set
			{
				if (_isNotDefault)
				{
					_isNotDefault = false;
				}

				_mouseState = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public MarqueeState MarqueeState
		{
			get
			{
				return _marqueeState;
			}
			internal set
			{
				if (_isNotDefault)
				{
					_isNotDefault = false;
				}

				_marqueeState = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public GamePadState GamePadState { get; internal set; }
#endif

		/// <summary>
		/// 
		/// </summary>
		public TouchCollection TouchState
		{
			get
			{
				return _touchState;
			}
			internal set
			{
				if (_isNotDefault)
				{
					_isNotDefault = false;
				}

				_touchState = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public KeyboardState KeyboardState
		{
			get
			{
				return _keyboardState;
			}
			internal set
			{
				if (_isNotDefault)
				{
					_isNotDefault = false;
				}

				_keyboardState = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static bool operator ==(InputState a, InputState b)
		{
			return !(a != b);
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static bool operator !=(InputState a, InputState b)
		{
			return a.Equals(b);
		}

		public bool IsDefault()
		{
			return !_isNotDefault;
		}
	}
}